<?php

use App\Helpers\CSRF;
use App\Helpers\URL;

if ($event !== "contactDelete_{$contactId}") { ?>
<?php $app->render('templates/dashboard_open', ['app' => $app, 'title' => 'Eliminar contacto']) ?>
<?php } ?>
<div id="<?= "contactDelete_{$contactId}" ?>" class="card col-4 is-horizontal-align flex-col">
  <div class="text-center">
    <header class="mb-2">
      <h2>Eliminar contacto</h2>
      <?php if (isset($error)) { ?>
        <?php $app->render('components/error', ['error' => $error]) ?>
      <?php } ?>
      <p>¿Estás seguro que deseas eliminar el siguiente contacto?</p>
    </header>
    <form action="<?= URL::event(['contacts', 'delete', $contactId], null, "contactDelete_{$contactId}") ?>" method="post" target=htmz>
      <input type="hidden" name="<?= CSRF::getVarname() ?>" value="<?= $app->local(CSRF::getVarname()) ?>">
      <p>
        <a href="<?= URL::event(['contacts', $contactId], "contactShow_{$contactId}", "contactDelete_{$contactId}") ?>" target=htmz class="button secondary">Cancelar</a>
        <input type="submit" value="Eliminar" class="button error">
      </p>
    </form>
  </div>
</div>
<?php if ($event !== "contactDelete_{$contactId}") { ?>
<?php $app->render('templates/dashboard_close', ['app' => $app]) ?>
<?php } ?>
